<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var a = [5,3,4,1,2]
        var d = 0
        for (i = 0 ; i <= a.length-1; i++) {
            for (b=0; b<=a.length-i-1; b++) {
                if (a[b] >a [b+1]) {
                    var c = a[b]
                    a[b] = a[b+1]
                    a[b+1] = c
                }
            }
        }
        console.log(a);
    </script>
</body>
</html>